<?php

#--------------------------------------------------
# ALL INCLUDES + STANDARD-VALUES
#--------------------------------------------------
include_once ("include/config.inc");
include_once ("include/template.inc");
include_once ("include/class.db.php5");
include_once ("include/class.tools.php5");
$svo = new db("svoptik");
$tools = new tool();

include_once ("include/global_fix_extern.inc");

#--------------------------------------------------
# CREATE TEMPLATE
#--------------------------------------------------
$t = new Template("templates", "keep");
$t->set_file(array (
	"page" => "svoptik.tpl",
	"ticker" => "ticker.tpl",
	"navi" => "navi.tpl",
	"mail" => "mailform.tpl"
));
#--------------------------------------------------
$t->set_var(array (
	"FORWARD" => ""
));

#--------------------------------------------------
# CREATE NAVIGATION RIGHT
#--------------------------------------------------
$links = "";
$url[0] = array (
	"URL" => "",
	"URL-TEXT" => ""
);
$url[1] = array (
	"URL" => "",
	"URL-TEXT" => ""
);
$url[2] = array (
	"URL" => "",
	"URL-TEXT" => ""
);
for ($i = 0; $i < count($url); $i++) {
	$links .= "
	        <tr height=\"15\">
				<td valign=\"top\"><img src=\"standard/spacer.gif\" width=\"20\" height=\"15\" border=\"0\" alt=\"\"></td>
				<td valign=\"top\"><a href=\"" . $url[$i]['URL'] . "\" class=\"sitenav\">" . $url[$i]['URL-TEXT'] . "</a></td>
				<td valign=\"top\"><img src=\"standard/spacer.gif\" width=\"20\" height=\"15\" border=\"0\" alt=\"\"></td>
			</tr>
	       ";
}
$t->set_var(array (
	"LINKS" => $links,
	"BANNER" => $banner
));
$right_nav = $t->parse("", "navi", true);
#--------------------------------------------------

#--------------------------------------------------
# CREATE ALL-TIME SAME THINGS
#--------------------------------------------------
include_once ("include/sameThings.php5");

#--------------------------------------------------

#--------------------------------------------------
# CREATE CONTENT "MAIL @ RED EAGLES RATHENOW"
#--------------------------------------------------
global $mail_name, $mail_text, $mail_email, $mail_to, $send;

$mail_addies[] = array (
	"NAME" => "1. Vorsitz (Martin Skowronek)",
	"MAIL" => "vorsitz.skowronek@red-eagles-rathenow.de"
);
$mail_addies[] = array (
	"NAME" => "2. Vorsitz (Harry Weber)",
	"MAIL" => "martinskowronek@gmx.de"
);
$mail_addies[] = array (
	"NAME" => "Kassenwart (Vivien Skowronek)",
	"MAIL" => "kassenwart@red-eagles-rathenow.de"
);
$mail_addies[] = array (
	"NAME" => "Schiedsrichterwart (Daniel Golze)",
	"MAIL" => "schiedsrichterwart@red-eagles-rathenow.de"
);
//$mail_addies[] = array("NAME" => "Sponsoring/<br>&Ouml;ffentlichkeitsarbeit", "MAIL" => "sponsoring@sv-optik.de");
$mail_addies[] = array (
	"NAME" => "Webmaster (nulleins-media)",
	"MAIL" => "webmaster@red-eagles-rathenow.de"
);
$mail_addies[] = array (
	"NAME" => "Webmaster (Michael Gentzsch)",
	"MAIL" => "mastergenny@red-eagles-rathenow.de"
);
$mail_addies[] = array (
	"NAME" => "----------",
	"MAIL" => ""
);
//$mail_addies[] = array (
//	"NAME" => "Herren I (Daniel B&auml;umer)",
//	"MAIL" => "herren1@sv-optik.de"
//);
//$mail_addies[] = array (
//	"NAME" => "Herren II (Carsten Jagla)",
//	"MAIL" => "herren2@sv-optik.de"
//);
$mail_addies[] = array (
	"NAME" => "Herren / U16m / U12 (Martin Skowronek)",
	"MAIL" => "vorsitz.skowronek@red-eagles-rathenow.de"
);
$mail_addies[] = array (
	"NAME" => "Damen / U18w (Daniel Golze)",
	"MAIL" => "schiedsrichterwart@red-eagles-rathenow.de"
);
//$mail_addies[] = array("NAME" => "U20 II (Andre Dobkowicz)",                  "MAIL" => "u20_2@sv-optik.de");
//$mail_addies[] = array("NAME" => "U20 II - Trainer (Robert Jahn)",            "MAIL" => "traineru20_2@sv-optik.de");
//$mail_addies[] = array("NAME" => "U18 (Benny Kosiol)",                        "MAIL" => "u18@sv-optik.de");

if (empty ($mail_to))
	$mail_to_options = "<option value=\"\" selected>Bitte w&auml;hlen Sie aus</option>";
else
	$mail_to_options = "<option value=\"" . $mail_to . "\">" . $mail_addies[$mail_to]['NAME'] . "</option>";
$mail_to_options .= "<option value=\"\">----------</option>";
for ($i = 0; $i < count($mail_addies); $i++)
	$mail_to_options .= "<option value=\"" . $i . "\">" . $mail_addies[$i]['NAME'] . "</option>";

if (empty ($link_url))
	$link_url = "http://www.";
$t->set_var(array (
	"NAME" => $mail_name,
	"EMAIL" => $mail_email,
	"TEXT" => $mail_text,
	"MAIL_TO" => $mail_to_options,
	"MSG" => ""
));

if (empty ($send))
	$content = $t->parse("", "mail", true);
else {
	if (empty ($mail_text) || empty ($mail_name) || empty ($mail_email) || !ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})", $mail_email) || empty ($mail_to)) {
		$t->set_var(array (
			"MSG" => "Bitte &uuml;berpr&uuml;fen Sie Ihre Eingaben!"
		));
		$content = $t->parse("", "mail", true);
	} else {
		$mail_subject = "E-Mail von " . $mail_name . " [" . $mail_email . "]";
		$mail_name = $mail_addies[$mail_to]['MAIL'];

		$header = "From:" . $mail_name . "<" . $mail_email . ">\n";
		$header .= "Reply-To: " . $mail_email . "\n";
		$header .= "X-Mailer: PHP/" . phpversion() . "\n";
		$header .= "X-Sender-IP: " . $REMOTE_ADDR . "\n";
		$header .= "Content-Type: text/plain";

		if (@ mail($mail_addies[$mail_to]['MAIL'], $mail_subject, $mail_text, $header))
			$content = "
					        <p align=\"center\" class=\"text\"><br><br><br>Ihre E-Mail wurde an " . $mail_addies[$mail_to]['NAME'] . " gesendet.<br><br><a href=\"javascript:window.location.replace('mail.php5');\" class=\"text\">zur&uuml;ck</a></p>
			              ";
		else
			$content = "
					        <p align=\"center\" class=\"text\"><br><br><br>Ihre E-Mail konnte nicht an " . $mail_addies[$mail_to]['NAME'] . " gesendet werden.<br><br></p>
			              ";
	}
}

#--------------------------------------------------

#--------------------------------------------------
# PARSE & OUTPUT
#--------------------------------------------------
$t->set_var(array (
	"navi" => $right_nav,
	"SYNCHRONIZE" => " ",
	"sitenav" => "INFOS -> MAIL @ RED EAGLES RATHENOW",
	"ticker" => $ticker,
	"content" => $content
));

$t->parse("ALL", "page", true);
$t->p("ALL");
?>
